<template>
  <div>
      <el-card >
        <el-form ref="form" status-icon label-width="100px"  style="padding-left: 100px;padding-right: 100px;">
          <el-form-item label="服务类型" style="text-align: left;">
            <el-select style="width: 30%;" v-model="type">
              <el-option
                    v-for="item in options"
                    :key="item.name"
                    :label="item.name"
                    :value="item.name"/>
            </el-select>
          </el-form-item>

          <el-form-item label="反馈内容">
            <el-input type="textarea" :autosize="{ minRows: 10, maxRows: 20}" v-model="data"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" style="width: 100%;"  @click="submit()">立即创建</el-button>
          </el-form-item>
        </el-form>

      </el-card>
  </div>
</template>

<script>
  export default {
    name: 'service2',
    data() {
      return {
        data:'',
        type:'',
        options:'',
      };
    },
    components: {

    },
    mounted() {
      this.getdata()
    },
    beforeDestroy() {

    },
    computed:{

    },
    methods: {
      getdata() {
        this.getRequest('/dd/getParentIdData/2')
        .then(successResponse => {
          if (successResponse.data.status == 200) {
            this.options=successResponse.data.obj;
          }
          else
            this.$message.error(successResponse.data.msg);
        })
        .catch(failResponse => {
          this.$message.error('网络不通畅');
        })
      },
      submit(){
        if(!this.data || !this.type){
          this.$message.error("服务类型 和 反馈内容 不能为空！");
          return;
        }
        this.postRequest('/service/create',{
          content:this.data,
          type:this.type,
          createUser:this.$store.state.userInfo.name
        })
        .then(successResponse => {
          if (successResponse.data.status == 200) {
            this.$message.success("添加成功！")
            this.data='';
            this.type='';
          }
          else
            this.$message.error(successResponse.data.msg);
        })
        .catch(failResponse => {
          this.$message.error('网络不通畅');
        })
      }
    },
  };
</script>

<style>

</style>
